package com.simon.hse.activity.safe.saferisk;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.simon.hse.MyApplication;
import com.simon.hse.R;
import com.simon.hse.activity.BaseActivity;
import com.simon.hse.activity.safe.jsa.RiskRecognitionAndSafeStepQuertActivity;
import com.simon.hse.activity.safe.safework.SafeTechnologyStepQuertActivity;
import com.simon.hse.activity.safe.workpermit.AddSpecialWorkPermitActivity;

import org.xutils.view.annotation.ContentView;
import org.xutils.view.annotation.Event;
import org.xutils.view.annotation.ViewInject;

/**
 * 申请安全交底和风险告知卡
 */
@SuppressWarnings("all")
@ContentView(R.layout.activity_apply_safe_risk)
public class ApplySafeAndRiskActivity extends BaseActivity {
    @ViewInject(R.id.tv_common_title)
    TextView mTv_common_title;

    @ViewInject(R.id.tv_apply_work_permit_xgbg)
    TextView mTv_apply_work_permit_xgbg;

    @ViewInject(R.id.ll_danger_stop_bottom)
    LinearLayout mLl_danger_stop_bottom;

    @ViewInject(R.id.ll_workunit)
    LinearLayout ll_workunit;
    @ViewInject(R.id.tv_workunit)
    TextView tv_workunit;

    @ViewInject(R.id.ll_workshop)
    LinearLayout ll_workshop;
    @ViewInject(R.id.tv_workshop)
    TextView tv_workshop;

    @ViewInject(R.id.ll_operator)
    LinearLayout ll_operator;
    @ViewInject(R.id.tv_operator)
    TextView tv_operator;

    @ViewInject(R.id.ll_start_time)
    LinearLayout ll_start_time;
    @ViewInject(R.id.tv_start_time)
    TextView tv_start_time;

    @ViewInject(R.id.ll_end_time)
    LinearLayout ll_end_time;
    @ViewInject(R.id.tv_end_time)
    TextView tv_end_time;

    private boolean isShowBottom = false;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mTv_common_title.setText("安全交底和风险告知卡");
//        Bundle bundle = getIntent().getExtras();
//        if (bundle == null) {
//            mLl_danger_stop_bottom.setVisibility(View.VISIBLE);
//            mTv_apply_work_permit_xgbg.setText("特殊作业许可证及相关附件信息");
//        } else {
//            mLl_danger_stop_bottom.setVisibility(View.INVISIBLE);
//            mTv_apply_work_permit_xgbg.setText("特殊作业许可证及相关表格");
//        }
    }

    @Event(value = {R.id.iv_common_left, R.id.iv_add_specila_work_permit, R.id.tv_submission, R.id.tv_save, R.id.iv_add_safe_technology_measures, R.id.iv_add_risk
            , R.id.ll_workunit, R.id.ll_workshop, R.id.ll_operator, R.id.ll_start_time, R.id.ll_end_time})
    private void finish(View view) {
        switch (view.getId()) {
            case R.id.iv_common_left:
                finish();
                break;
            case R.id.iv_add_specila_work_permit:
                Intent intent = new Intent(ApplySafeAndRiskActivity.this, AddSpecialWorkPermitActivity.class);
                Bundle bundle = new Bundle();
                intent.putExtras(bundle);
                startActivity(intent);
                break;
            case R.id.tv_submission:
                finish();
                break;
            case R.id.tv_save:
                finish();
                break;
            case R.id.iv_add_safe_technology_measures:
                startActivity(new Intent(ApplySafeAndRiskActivity.this, SafeTechnologyStepQuertActivity.class));
                break;
            case R.id.iv_add_risk:
                startActivity(new Intent(ApplySafeAndRiskActivity.this, RiskRecognitionAndSafeStepQuertActivity.class));
                break;
            case R.id.ll_workunit:
                initSafePop(ll_workunit, tv_workunit, MyApplication.getInstance().mSafeWorkUnitList);
                break;
            case R.id.ll_workshop:
                initSafePop(ll_workshop, tv_workshop, MyApplication.getInstance().mSafeWorkShopList);
                break;
            case R.id.ll_operator:
                initSafePop(ll_operator, tv_operator, MyApplication.getInstance().mSafeOperatorList);
                break;
            case R.id.ll_start_time:
                publishSafeDate(tv_start_time);
                break;
            case R.id.ll_end_time:
                publishSafeDate(tv_end_time);
                break;
        }
    }
}
